<template>
  <div class="head-nav">
    <div class="search-wrap" :class="is_active && 'active'">
      <i class="hm-icon icon-search"></i>
      <div class="search-input">
        <input 
        type="text" 
        name="keyword" 
        @focus="is_active = true" 
        @blur="is_active = keyword.length > 0" 
        v-model="keyword" 
        @keyup.enter="search"
        placeholder="请输入关键字进行查询"
      >
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'header',
  data() {
    return {
      keyword:'',
      is_active: false
    }
  },
  methods: {
    search() {
      // 将keyword放入store中
    }
  }
}
</script>

<style lang="less" scoped>
.head-nav {
  position: fixed;
  left: 0;
  right: 0;
  top:0;
  height: 55px;
  padding: 0 20px;
  border-bottom: 1px solid #cdcdcd;
  .search-wrap {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid #e6e6e6;
    background-color: #e6e6e6;
    border-radius: 4px;
    color: #999;
    .hm-icon {
      flex: 0 0 16px;
    }
    .search-input {
      flex: 1;
      margin-left: 5px;
      input {
        display: block;
        width: 100%;
        &:active {
          color: #333;
        }
      }
    }

    &.active {
      background-color: #cdcdcd;
      color: #666;
    }
  }
}
</style>
